﻿using System;
using System.Collections.Generic;
using System.Text;

using E.Model;
using E.DAL;

namespace E.BLL
{
    public class CourseBLL
    {
        private CourseDAL dal;

        public CourseBLL()
        {
            dal = new CourseDAL();
        }

        /// <summary>
        /// 获取课程类别列表
        /// </summary>
        /// <returns></returns>
        public IList<CourseCategoryModel> GetCourseCategoryList()
        {
            return dal.GetCourseCategoryList();
        }

        /// <summary>
        /// 获取认证列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetCertificateList()
        {
            return dal.GetCertificateList();
        }

        /// <summary>
        /// 获取项目列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetProjectList()
        {
            return dal.GetProjectList();
        }

        /// <summary>
        /// 获取内训公共项目列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetInternalPublicProjectList()
        {
            return dal.GetInternalPublicProjectList();
        }

        /// <summary>
        /// 获取认证和项目列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetAllCertificateAndProjectList()
        {
            return dal.GetAllCertificateAndProjectList();
        }

        /// <summary>
        /// 获取课程列表
        /// </summary>
        /// <param name="certificateid"></param>
        /// <returns></returns>
        public Dictionary<int, string> GetRelationCourseList(int certificateid)
        {
            return dal.GetRelationCourseList(certificateid);
        }

        /// <summary>
        /// 获取课程列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetCourseList()
        {
            return dal.GetCourseList();
        }

        /// <summary>
        /// 获取内训课程列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetInternalCourseList()
        {
            return dal.GetInternalCourseList();
        }

        /// <summary>
        /// 获取内训公共课程列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetInternalPublicCourseList()
        {
            return dal.GetInternalPublicCourseList();
        }

        /// <summary>
        /// 获取所有公共课程列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetAllPublicCourseList()
        {
            return dal.GetAllPublicCourseList();
        }

        /// <summary>
        /// 获取证书相关课程列表
        /// </summary>
        /// <param name="certificateID"></param>
        /// <returns></returns>
        public Dictionary<int, string> GetCourseListByCertificateID(int certificateID)
        {
            return dal.GetCourseListByCertificateID(certificateID);
        }

        /// <summary>
        /// 获取教师所属项目相关课程列表
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public Dictionary<int, string> GetCourseListByTeacherID(int teacherid)
        {
            return dal.GetCourseListByTeacherID(teacherid);
        }

        /// <summary>
        /// 获取认证相关课程ID列表
        /// </summary>
        /// <param name="certificateid"></param>
        /// <returns></returns>
        public IList<int> GetCourseIDListByCertificateID(int certificateid)
        {
            return dal.GetCourseIDListByCertificateID(certificateid);
        }

        /// <summary>
        /// 获取认证名称
        /// </summary>
        /// <param name="certificateid"></param>
        /// <returns></returns>
        public string GetCertificateNameByID(int certificateid)
        {
            return dal.GetCertificateNameByID(certificateid);
        }

        /// <summary>
        /// 获取认证或项目信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public CertificateModel GetCertificateProjectInfoById(int id)
        {
            return dal.GetCertificateProjectInfoById(id);
        }

        /// <summary>
        /// 添加认证或项目
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddCertificateProject(CertificateModel model)
        {
            return dal.AddCertificateProject(model);
        }

        /// <summary>
        /// 检查认证或项目名称是否重复
        /// </summary>
        /// <param name="coursename"></param>
        /// <param name="selfid"></param>
        /// <returns></returns>
        public bool CheckExistProjectName(string name, int selfid)
        {
            return dal.CheckExistProjectName(name, selfid);
        }

        /// <summary>
        /// 更新认证或项目信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateCertificateProject(CertificateModel model)
        {
            return dal.UpdateCertificateProject(model);
        }

        /// <summary>
        /// 获取课程列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public IList<ShortCourseModel> GetPublicCourseList(SearchCourseModel searchModel)
        {
            return dal.GetPublicCourseList(searchModel);
        }

        /// <summary>
        /// 获取公共课程信息
        /// </summary>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public CourseModel GetPublicCourseInfoById(int courseid)
        {
            return dal.GetPublicCourseInfoById(courseid);
        }

        /// <summary>
        /// 添加公共课程
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddPublicCourse(CourseModel model)
        {
            return dal.AddPublicCourse(model);
        }

        /// <summary>
        /// 更新公共课程信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdatePublicCourse(CourseModel model)
        {
            return dal.UpdatePublicCourse(model);
        }

        /// <summary>
        /// 编辑认证与课程关系
        /// </summary>
        /// <param name="certificateid"></param>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public int EditRelation(int certificateid, string[] courseid)
        {
            return dal.EditRelation(certificateid, courseid);
        }

        /// <summary>
        /// 激活课程
        /// </summary>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public int ActiveCourse(int courseid)
        {
            return dal.ActiveCourse(courseid);
        }

        /// <summary>
        /// 冻结课程
        /// </summary>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public int FreezeCourse(int courseid)
        {
            return dal.FreezeCourse(courseid);
        }

        #region 内训公共课

        /// <summary>
        /// 检查课程名称是否重复
        /// </summary>
        /// <param name="coursename"></param>
        /// <param name="pid"></param>
        /// <param name="selfid"></param>
        /// <returns></returns>
        public bool CheckExistPublicCourseName(string coursename, int pid, int selfid)
        {
            return dal.CheckExistPublicCourseName(coursename, pid, selfid);
        }

        /// <summary>
        /// 获取内训公共课程列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public CourseListModel GetInternalPublicCourseListByCondition(SearchCourseModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetInternalPublicCourseListByCondition(searchModel, pageSize, pageIndex);
        }

        /// <summary>
        /// 获取课件列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public CourseWareListModel GetInternalPublicCourseWareListByCondition(SearchCourseWareModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetInternalPublicCourseWareListByCondition(searchModel, pageSize, pageIndex);
        }

        /// <summary>
        /// 获取所有公共课程项目列表及作为公共课程的旗舰认证
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetAllInternalPublicProjectList()
        {
            return dal.GetAllInternalPublicProjectList();
        }

        #endregion

        #region 内训

        /// <summary>
        /// 检查课程名称是否重复
        /// </summary>
        /// <param name="coursename"></param>
        /// <param name="pid"></param>
        /// <param name="selfid"></param>
        /// <returns></returns>
        public bool CheckExistCourseName(string coursename, int pid, int selfid)
        {
            return dal.CheckExistCourseName(coursename, pid, selfid);
        }

        /// <summary>
        /// 获取老师项目组信息
        /// </summary>
        /// <param name="teacherid"></param>
        /// <returns></returns>
        public Dictionary<int, string> GetTeacherProjectList(int teacherid)
        {
            return dal.GetTeacherProjectList(teacherid);
        }

        /// <summary>
        /// 添加内训课程
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddInternalCourse(CourseModel model)
        {
            return dal.AddInternalCourse(model);
        }

        /// <summary>
        /// 更新内训课程信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateInternalCourse(CourseModel model)
        {
            return dal.UpdateInternalCourse(model);
        }

        /// <summary>
        /// 获取内训项目列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetInternalProjectList()
        {
            return dal.GetInternalProjectList();
        }

        /// <summary>
        /// 获取内训课程列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<int, string> GetAllCourseList()
        {
            return dal.GetAllCourseList();
        }

        /// <summary>
        /// 获取内训课程信息
        /// </summary>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public CourseModel GetInternalCourseInfoById(int courseid)
        {
            return dal.GetInternalCourseInfoById(courseid);
        }

        /// <summary>
        /// 获取课程列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public CourseListModel GetInternalCourseListByCondition(SearchCourseModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetInternalCourseListByCondition(searchModel, pageSize, pageIndex);
        }


        /// <summary>
        /// 获取内训自选课
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public InternalFreeCourseListModel GetInternalFreeCourseListByCondition(InternalFreeCourseSearchModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetInternalFreeCourseListByCondition(searchModel, pageSize, pageIndex);
        }

        /// <summary>
        /// 自选课程报名
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="classid"></param>
        /// <param name="courseid"></param>
        /// <param name="projectid"></param>
        /// <returns></returns>
        public int SignUpInternalFreeCourse(int userid, int courseid, int projectid)
        {
            return dal.SignUpInternalFreeCourse(userid, courseid, projectid);
        }

        /// <summary>
        /// 判断是否有需要在学习courseid的课程之前要必须完成的课程
        /// </summary>
        /// <param name="courseid"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public bool IsNeedFinishPrevCourse(int courseid, int userid)
        {
            return dal.IsNeedFinishPrevCourse(courseid, userid);
        }

        #endregion

        #region 技能组

        /// <summary>
        /// 判断新建的技能组名称是否已经存在
        /// </summary>
        /// <param name="skillGroupName"></param>
        /// <returns></returns>
        public bool IsExistSkillGroupName(string skillGroupName)
        {
            return dal.IsExistSkillGroupName(skillGroupName);

        }

        /// <summary>
        /// 通过Id获得技能组
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public SkillGroup GetSkillGroupModel(int id)
        {
            return dal.GetSkillGroupModel(id);
        }

        /// <summary>
        /// 增加新技能组
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddSkillGroup(SkillGroup model)
        {
            return dal.AddSkillGroup(model);
        }

        /// <summary>
        /// 更新技能组
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateSkillGroup(SkillGroup model)
        {
            return dal.UpdateSkillGroup(model);
        }

        /// <summary>
        /// 获得所有技能组
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public SkillGroupListModel GetSkillAllGroupList(string name)
        {
            return dal.GetSkillGroupList(name);
        }
        #endregion

        #region 内训课件

        /// <summary>
        /// 获取课件信息
        /// </summary>
        /// <param name="courseWareId"></param>
        /// <returns></returns>
        public CourseWareModel GetCourseWareInfoById(int courseWareId)
        {
            return dal.GetCourseWareInfoById(courseWareId);
        }

        /// <summary>
        /// 获取课件视频地址
        /// </summary>
        /// <param name="courseWareId"></param>
        /// <returns></returns>
        public string GetVideoUrlById(int id)
        {
            return dal.GetVideoUrlById(id);
        }

        /// <summary>
        /// 获取课件信息（列表）
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IList<CourseWareModel> GetCourseWareInfoById(string[] id)
        {
            return dal.GetCourseWareInfoById(id);
        }

        /// <summary>
        /// 添加课件
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddCourseWare(CourseWareModel model)
        {
            return dal.AddCourseWare(model);
        }

        /// <summary>
        /// 更新课件
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateCourseWare(CourseWareModel model)
        {
            return dal.UpdateCourseWare(model);
        }

        /// <summary>
        /// 获取课件列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public CourseWareListModel GetCourseWareListByCondition(SearchCourseWareModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetCourseWareListByCondition(searchModel, pageSize, pageIndex);
        }

        /// <summary>
        /// 获取课件列表
        /// </summary>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public IList<CourseWareModel> GetCourseWareListByCourseID(int courseid)
        {
            return dal.GetCourseWareListByCourseID(courseid);
        }

        /// <summary>
        /// 删除课件
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DelCourseWare(int id)
        {
            return dal.DelCourseWare(id);
        }

        /// <summary>
        /// 更新页码（删除某一页时）
        /// </summary>
        /// <param name="startNumber"></param>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public int UpdateSerialNumber(int startNumber, int courseid)
        {
            return dal.UpdateSerialNumber(startNumber, courseid);
        }

        /// <summary>
        /// 获取课件总数
        /// </summary>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public int GetCourseWarePageCount(int courseid)
        {
            return dal.GetCourseWarePageCount(courseid);
        }

        #endregion

        #region BookMark

        /// <summary>
        /// 获取用户书签
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public int GetUserBookMark(int userid, int courseid)
        {
            return dal.GetUserBookMark(userid, courseid);
        }

        /// <summary>
        /// 书签处理
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="courseid"></param>
        /// <param name="pageNumber"></param>
        /// <returns></returns>
        public int BookMarkHandle(int userid, int courseid, int pageNumber)
        {
            return dal.BookMarkHandle(userid, courseid, pageNumber);
        }

        #endregion
    }
}
